@@ -22,6 +22,7 @@ from utils.redis.connect import r |
||
22 | 22 |
from utils.redis.rbrief import set_brief_info |
23 | 23 |
from utils.redis.rgroup import set_group_info, set_group_info_by_id |
24 | 24 |
from utils.redis.rkeys import GROUP_LAST_PHOTO_PK, TODAY_INCOME, TODAY_UPLOAD_PHOTO_AMOUNT, WEEK_INCOME, WEEK_SOLD |
25 |
+from utils.redis.rlock import upload_lock |
|
25 | 26 |
from utils.redis.rorder import set_lensman_order_record |
26 | 27 |
from utils.redis.rprice import get_lensman_price_fixed, set_lensman_price_fixed |
27 | 28 |
from utils.redis.rprofile import set_profile_info |
@@ -170,7 +171,7 @@ def lensman_photo_upload_api(request): |
||
170 | 171 |
|
171 | 172 |
group_id = group.group_id |
172 | 173 |
|
173 |
- if photo and r.acquire_lock('{}:{}:{}'.format(group_id, user_id, photo.name), time=60): |
|
174 |
+ if photo and upload_lock(group_id, user_id, photo): |
|
174 | 175 |
# 写 PhotosInfo 表 |
175 | 176 |
photo_info = file_save(photo, prefix='photo', ext='jpeg', watermark=True, thumbnail=True) |
176 | 177 |
|
@@ -293,7 +294,7 @@ def lensman_origin_photo_upload_api(request): |
||
293 | 294 |
order.reback_at = tc.utc_datetime() |
294 | 295 |
order.save() |
295 | 296 |
|
296 |
- if photo and r.acquire_lock('{}:{}:{}'.format(order_id, user_id, photo.name), time=60): |
|
297 |
+ if photo and upload_lock(group_id, user_id, photo): |
|
297 | 298 |
# 写 PhotosInfo 表 |
298 | 299 |
photo_info = file_save(photo, prefix='photo', ext='jpeg') |
299 | 300 |
|
@@ -24,6 +24,7 @@ from utils.redis.rgroup import (del_group_photo_thumbup_flag, get_group_info, ge |
||
24 | 24 |
set_group_photo_comment_list, set_group_photo_data, set_group_photo_thumbup_flag, |
25 | 25 |
set_group_photo_thumbup_list, set_group_users_info) |
26 | 26 |
from utils.redis.rkeys import GROUP_LAST_PHOTO_PK, GROUP_PHOTO_WATCHER_SET, GROUP_USERS_PASSED_SET |
27 |
+from utils.redis.rlock import upload_lock |
|
27 | 28 |
from utils.redis.rorder import get_lensman_order_record |
28 | 29 |
from utils.redis.rprice import get_lensman_price_fixed |
29 | 30 |
from utils.sql.raw import PAI2_HOME_API |
@@ -278,7 +279,7 @@ def flyimg_upload_api(request): |
||
278 | 279 |
except GroupUserInfo.DoesNotExist: |
279 | 280 |
return response(GroupUserStatusCode.GROUP_USER_NOT_FOUND) |
280 | 281 |
|
281 |
- if photo and r.acquire_lock('{}:{}:{}'.format(group_id, user_id, photo.name), time=60): |
|
282 |
+ if photo and upload_lock(group_id, user_id, photo): |
|
282 | 283 |
photo_info = file_save(photo, prefix='fly', ext='jpeg', thumbnail=True) |
283 | 284 |
|
284 | 285 |
# 群组照片记录创建 |
@@ -0,0 +1,9 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+from filemd5 import calculate_md5 |
|
4 |
+ |
|
5 |
+from utils.redis.connect import r |
|
6 |
+ |
|
7 |
+ |
|
8 |
+def upload_lock(group_id, user_id, file_): |
|
9 |
+ return r.acquire_lock('{}:{}:{}'.format(group_id, user_id, calculate_md5(file_))) |